package com.wantong.jianpu.activitys;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.lxj.xpopup.XPopup;
import com.wantong.jianpu.BR;
import com.wantong.jianpu.R;
import com.wantong.jianpu.base.BaseXActivity;
import com.wantong.jianpu.databinding.ActivityAssignBinding;
import com.wantong.jianpu.viewmodels.AssignViewModel;

/**
 * 指派维修人员
 */
public class AssignActivity extends BaseXActivity<ActivityAssignBinding, AssignViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_assign;
    }


    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        setToolbar(binding.baseToolBar);
        viewModel.repairOrderId=getIntent().getExtras().getString("id");
        viewModel.rankDialogEvent.observe(this, strings -> {
            new XPopup.Builder(AssignActivity.this)
                    .asBottomList("请选择维修等级", strings,
                            (position, text) -> {
                                viewModel.setRankPosition(position);
                            }).show();
        });

        viewModel.userDialogEvent.observe(this, strings -> {
            new XPopup.Builder(AssignActivity.this)
                    .asBottomList("请选择维修人员", strings,
                            (position, text) -> {
                                viewModel.setUserPosition(position);
                            }).show();
        });

        viewModel.assistDialogEvent.observe(this, strings -> {
            new XPopup.Builder(AssignActivity.this)
                    .asBottomList("请选择协助人员", strings,
                            (position, text) -> {
                                viewModel.setAssistUserPosition(position);
                            }).show();
        });
    }
}